home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
tex
/
td187src.lzh
/
MTALERTS.I
< prev
next >
Wrap
Text File
|
1991-06-08
|
30KB
|
604 lines
(*#######################################################################
M A G I C A L E R T S
#######################################################################
V2.01 13.12.90 Jens Pirnay Korrektur von doAlert
V2.0 17.10.90 Peter Hellinger Anpassung an neues MagicSys
V1.0 29.07.90 Peter Hellinger TDI-Modula-2
#######################################################################*)
IMPLEMENTATION MODULE mtAlerts;
(*------------------------------*)
(* COMPILERSWITCHES *)
(*------------------------------*)
(* TDI-Version: DEAKTIVIERT *)
(*------------------------------*)
(* V- Overflow-Checks *)
(* R- Range-Checks *)
(* S- Stack-Check *)
(* N- NIL-Checks *)
(* T- TDI-Compiler vor 3.01 *)
(* Q+ Branch statt Jumps *)
(* *)
(*------------------------------*)
(* MM2-Version: AKTIVIERT *)
(*------------------------------*)
(*$R- Range-Checks *)
(*$S- Stack-Check *)
(* *)
(*------------------------------*)
FROM SYSTEM IMPORT ADDRESS, ADR;
FROM MagicAES IMPORT GBOX, GIMAGE, GIBOX, GBUTTON, GSTRING, SELECTABLE,
DEFAULT, Exit, LASTOB, OUTLINED, OBJECT, GrafMkstate;
FROM MagicSys IMPORT Nil, Null,
Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7,
Bit8, Bit9, Bit10, Bit11, Bit12, Bit13, Bit14, Bit15,
LOC, Byte, ByteSet, sWORD, sINTEGER, sCARDINAL, sBITSET,
lWORD, lINTEGER, lCARDINAL, lBITSET,
CastToChar, CastToByte, CastToByteset, CastToInt,
CastToCard, CastToBitset, CastToWord, CastToLInt,
CastToLCard, CastToLBitset, CastToLWord, CastToAddr;
FROM mtDials IMPORT DIALOG, NewDial, CSCREEN, CMOUSE, CPOS, DialCenter,
DSTART, DFINISH, DialForm, DialDraw, DialDo;
FROM MagicStrings IMPORT Assign, Length;
IMPORT MagicAES;
CONST cMax = 39;
CONST Box = 0;
Mover = 1;
CONST Note = 0;
Wait = 1;
Stop = 2;
User = 3;
TYPE tString = ARRAY [0..cMax] OF CHAR;
tImage = ARRAY [0..31] OF lCARDINAL;
VAR Tree: ARRAY [0..11] OF OBJECT;
Image: ARRAY [Note..User] OF tImage;
AlertText: ARRAY [0..7] OF tString;
Icon: MagicAES.BITBLK;
Dialog: DIALOG;
ChWidth: sINTEGER;
ChHeight: sINTEGER;
IconColor: sINTEGER;
PROCEDURE PrepareAlert;
VAR i: sINTEGER;
BEGIN
MagicAES.GrafHandle (i, ChWidth, ChHeight, i, i);
Tree[Box].obNext:= -1;
Tree[Box].obHead:= 1;
Tree[Box].obTail:= 0;
Tree[Box].obType:= GBOX;
Tree[Box].obFlags:= {};
Tree[Box].obState:= {OUTLINED};
Tree[Box].Box.char:= 0C;
Tree[Box].Box.frame:= 2C;
Tree[Box].Box.flags:= {Bit15, Bit11};
Tree[Box].obX:= 0;
Tree[Box].obY:= 0;
Tree[Box].obWidth:= 16;
Tree[Box].obHeight:= 0;
Tree[Mover].obNext:= -1;
Tree[Mover].obHead:= -1;
Tree[Mover].obTail:= -1;
Tree[Mover].obType:= 1119H;
Tree[Mover].obFlags:= {};
Tree[Mover].obState:= {OUTLINED};
Tree[Mover].Box.char:= 0C;
Tree[Mover].Box.frame:= 1C;
Tree[Mover].Box.flags:= {Bit15, Bit11};
Tree[Mover].obX:= 0;
Tree[Mover].obY:= 0;
Tree[Mover].obWidth:= 16;
Tree[Mover].obHeight:= ChHeight;
MagicAES.ObjcAdd (ADR(Tree), Box, Mover);
END PrepareAlert;
PROCEDURE doAlert (xp, yp, mode, def: sINTEGER; VAR str: ARRAY OF CHAR): sINTEGER;
VAR i, j, h, c: sINTEGER;
text, butt: sINTEGER;
ioff, off: sINTEGER;
w, hi, objc: sINTEGER;
icon: BOOLEAN;
b: sBITSET;
BEGIN
PrepareAlert;
FOR i:= 0 TO 7 DO AlertText[i, 0]:= 0C; END;
i:= 0; h:= Length (str); objc:= 2; icon:= TRUE; ioff:= ChWidth * 4;
IF (i >= h) OR (str[0] # '[') THEN RETURN -1; END;
CASE str[1] OF
'1': Icon.biData:= ADR (Image[Note]);|
'2': Icon.biData:= ADR (Image[Wait]);|
'3': Icon.biData:= ADR (Image[Stop]);|
'4': Icon.biData:= ADR (Image[User]);|
ELSE icon:= FALSE;
END;
IF icon THEN
ioff:= (ChWidth * 2) + 32;
Icon.biWb:= 4;
Icon.biHl:= 32;
Icon.biX:= 0;
Icon.biY:= 0;
Icon.biColor:= IconColor;
Tree[objc].obNext:= -1;
Tree[objc].obHead:= -1;
Tree[objc].obTail:= -1;
Tree[objc].obType:= GIMAGE;
Tree[objc].obFlags:= {};
Tree[objc].obState:= {};
Tree[objc].ImagePtr:= ADR (Icon);
Tree[objc].obX:= ChWidth;
Tree[objc].obY:= ChHeight;
Tree[objc].obWidth:= 32;
Tree[objc].obHeight:= 32;
MagicAES.ObjcAdd (ADR(Tree), Box, objc);
INC (objc);
END;
i:= 2;
WHILE (str[i] # '[') DO
IF i > h THEN RETURN -1; END; INC (i);
END;
(* Textzeilen auslesen *)
text:= 0; c:= 0;
LOOP
j:= 0; INC (i);
IF i > h THEN RETURN -1; END;
WHILE (str[i] # '|') AND (str[i] # ']') AND (i <= h) AND (j < cMax) DO
AlertText[text, j]:= str[i]; INC (i); INC (j);
END;
AlertText [text, j]:= 0C;
Tree[objc].obNext:= -1;
Tree[objc].obHead:= -1;
Tree[objc].obTail:= -1;
Tree[objc].obType:= GSTRING;
Tree[objc].obFlags:= {};
Tree[objc].obState:= {};
Tree[objc].StringPtr:= ADR (AlertText[text]);
Tree[objc].obX:= ioff;
Tree[objc].obY:= ChHeight + (text * ChHeight);
Tree[objc].obWidth:= ChWidth * j;
Tree[objc].obHeight:= ChHeight;
MagicAES.ObjcAdd (ADR(Tree), Box, objc);
IF Tree[Box].obWidth <= Tree[objc].obWidth THEN
Tree[Box].obWidth:= ioff + Tree[objc].obWidth + 32;
END;
INC (objc);
INC (text);
IF (str[i] = ']') OR (text > 4) THEN EXIT; END;
END;
c:= objc - 1;
WHILE (str[i] # '[') DO
IF i > h THEN RETURN -1; END; INC (i);
END;
(* Buttons auslesen *)
butt:= 0; w:= ioff;
LOOP
AlertText[butt + text, 0]:= ' '; j:= 1; INC (i);
IF i > h THEN RETURN -1; END;
WHILE (str[i] # '|') AND (str[i] # ']') AND (i <= h) AND (j < cMax) DO
AlertText[butt + text, j]:= str[i]; INC (i); INC (j);
END;
AlertText [butt + text, j]:= ' '; INC (j);
AlertText [butt + text, j]:= 0C;
Tree[objc].obNext:= -1;
Tree[objc].obHead:= -1;
Tree[objc].obTail:= -1;
Tree[objc].obType:= 0121AH;
IF butt = def - 1 THEN Tree[objc].obFlags:= {DEFAULT, SELECTABLE, Exit};
ELSE Tree[objc].obFlags:= {Exit, SELECTABLE};
END;
Tree[objc].obState:= {};
Tree[objc].StringPtr:= ADR (AlertText[butt + text]);
IF (Tree[c].obY + (2 * ChHeight)) < (40 + ChHeight) THEN
Tree[objc].obY:= 40 + ChHeight;
ELSE
Tree[objc].obY:= Tree[c].obY + (2 * ChHeight);
END;
Tree[objc].obWidth:= ChWidth * (j - 1);
(* Buttons auf gleiche Größe bringen *)
IF butt > 0 THEN
IF Tree[objc].obWidth < Tree[objc - 1].obWidth THEN
Tree[objc].obWidth:= Tree[objc - 1].obWidth;
ELSIF Tree[objc].obWidth > Tree[objc - 1].obWidth THEN
Tree[objc - 1].obWidth:= Tree[objc].obWidth;
END;
END;
Tree[objc].obHeight:= ChHeight;
MagicAES.ObjcAdd (ADR(Tree), Box, objc);
INC (w, Tree[objc].obWidth + (ChWidth * 2));
INC (objc);
INC (butt);
IF (str[i] = ']') OR (butt > 2) THEN EXIT; END;
END;
IF Tree[Box].obWidth < w THEN
Tree[Box].obWidth:= w + 48;
END;
Tree[Box].obHeight:= Tree[objc - 1].obY + (2 * ChHeight);
Tree[Mover].obX:= Tree[Box].obWidth - Tree[Mover].obWidth;
(* Buttons zentrieren *)
DEC (objc);
CASE butt OF
1: Tree[objc].obX:= (Tree[Box].obWidth - Tree[objc].obWidth) DIV 2;
|
2: w:= Tree[objc - 1].obWidth + Tree[objc].obWidth;
w:= ((Tree[Box].obWidth - w) DIV 2) - ChWidth;
Tree[objc - 1].obX:= w;
Tree[objc].obX:= w + (ChWidth * 2) + Tree[objc - 1].obWidth;
|
3: w:= Tree[objc - 2].obWidth + Tree[objc - 1].obWidth + Tree[objc].obWidth;
w:= ((Tree[Box].obWidth - w) DIV 2) - (ChWidth * 2);
Tree[objc - 2].obX:= w;
Tree[objc - 1].obX:= w + (ChWidth * 2) + Tree[objc - 2].obWidth;